/**
 * Created by Administrator on 2015/12/29.
 */
angular.module('ddfd.controller',[])
  .controller('ddfdCtrl',['$scope','ddfdService','$localstorage','$cordovaBarcodeScanner','$ionicPopup','$timeout',function($scope,ddfdService,$localstorage,$cordovaBarcodeScanner,$ionicPopup,$timeout){
    $scope.params={};
    $scope.$on('$ionicView.enter', function(event, data) {
      $scope.params=ddfdService.getParams();
      $scope.params.MobilePhone="";
      $scope.params.BarSimCard={};
      $scope.params.IdCard={};
      if($localstorage.get("LOG_FLAG")=="1"){
        ddfdService.insertLog("订单返档").then(function(data){
          //console.log("插入日志"+angular.toJson(data));
        },function(error){
          //console.log("插入日志失败，请联系管理员");
        });
      }

    });


    $scope.readSimCard=function(){
      var mac=$localstorage.get("mac");
      if(mac){
        var param={"mac":mac};
      ddfdService.readSimCard(param);}
      else{
        var alertPopup=$ionicPopup.alert({
          title:'读取失败',
          template:"请先去用户中心连接蓝牙！",
          okText: '确定', // String (默认: 'OK')。OK按钮的文字。
          okType: 'item-customer-bg-darkred', // String (默认: 'button-positive')。OK按钮的类型。
        });
      }
    };

    //$scope.params.BarSimCard.text="8986011527710131346";

    //根据条形码扫描iccid
    $scope.saomiao=function(){
      $cordovaBarcodeScanner
        .scan()
        .then(function (result) {
          $scope.params.BarSimCard=angular.fromJson(result);
          $scope.params.QueryUserBySimParams.QryType= "1";
          var text=$scope.params.BarSimCard.text.substring(0,$scope.params.BarSimCard.text.length-1);
          $scope.params.BarSimCard.text=text;
          $scope.params.QueryUserBySimParams.QryCode= $scope.params.BarSimCard.text;
          queryUserBySim($scope.params.QueryUserBySimParams);

        },
        function (error) {
        });
      //$scope.params.QueryUserBySimParams.QryType= "1";
      //$scope.params.QueryUserBySimParams.QryCode= $scope.params.BarSimCard.text;
      //queryUserBySim($scope.params.QueryUserBySimParams);
    };

    $scope.ReadIccid=function(){
      $scope.params.BlueSimCard={};
      var mac=$localstorage.get("mac");
      if(mac) {
          var param={"mac":mac};
        ddfdService.ReadIccid(param,function(success){
          $scope.params.BlueSimCard=angular.fromJson(success);
          if($scope.params.BlueSimCard.retCode=="0"){
            $scope.params.BarSimCard.text = $scope.params.BlueSimCard.ICCID;
            $scope.params.QueryUserBySimParams.QryType = "1";
            $scope.params.QueryUserBySimParams.QryCode = $scope.params.BarSimCard.text;
            queryUserBySim($scope.params.QueryUserBySimParams);
          }else{
            var alertPopup=$ionicPopup.alert({
              title:'读取失败',
              template:"请重新尝试读取",
              okText: '确定', // String (默认: 'OK')。OK按钮的文字。
              okType: 'item-customer-bg-darkred', // String (默认: 'button-positive')。OK按钮的类型。
            });
          }
        },function(error){
          var alertPopup=$ionicPopup.alert({
            title:'读取失败',
            template:"请重新读取，确认已经插卡",
            okText: '确定', // String (默认: 'OK')。OK按钮的文字。
            okType: 'item-customer-bg-darkred', // String (默认: 'button-positive')。OK按钮的类型。
          });
        });
      }else{
        var alertPopup=$ionicPopup.alert({
          title:'读取失败',
          template:"请先去用户中心连接蓝牙！",
          okText: '确定', // String (默认: 'OK')。OK按钮的文字。
          okType: 'item-customer-bg-darkred', // String (默认: 'button-positive')。OK按钮的类型。
        });
      }
    }

    $scope.readIdCard=function(){
      var mac=$localstorage.get("mac");
      if(mac){
        var param={"mac":mac};
        ddfdService.readIdCard(param);
        if($scope.numvalid){
          $scope.params.tijiao=1;
        }else{
          $scope.params.tijiao=0;
        }
      }
      else{
        var alertPopup=$ionicPopup.alert({
          title:'读取失败',
          template:"请先去用户中心连接蓝牙！",
          okText: '确定', // String (默认: 'OK')。OK按钮的文字。
          okType: 'item-customer-bg-darkred', // String (默认: 'button-positive')。OK按钮的类型。
        });
      }
    };
    //手指触碰改变popover样式
    $scope.color=function(index){
      $scope.colorindex=index;
    };

    //手机号码输入框 离开焦点
    $scope.validMobilePhone=function(isValid)
    {
      //判断手机号的校验合法的情况下
      $scope.numvalid=isValid;
      if(isValid)
      {
        $scope.params.searchUserInfoByPhone.mobilePhone=$scope.params.MobilePhone;
        validMobilePhone($scope.params.searchUserInfoByPhone);
      }
      else//不合法
      {
      }
      if($scope.params.IdCard.name){
        $scope.params.tijiao=1;
      }else{
        $scope.params.tijiao=0;
      }

      }


    //调用手机号校验的接口
    function validMobilePhone(params)
    {
      //console.log(params);
      ddfdService.validMobilePhone(params).then(function(data){

          if(data.respCode=="-1")//校验失败
          {
            var alertPopup=$ionicPopup.alert({
              title:'校验失败',
              template:data.respDesc,
              okText: '确定', // String (默认: 'OK')。OK按钮的文字。
              okType: 'item-customer-bg-darkred', // String (默认: 'button-positive')。OK按钮的类型。
            });
          }
          else //校验成功
          {

            //校验成功以后要根据返回值中的data.data.sysCode来判断将返回来的参数放到哪个结构体中，
            //以备后面确认接口的使用
            //$scope.params.ValidMobilePhoneData2G={};
            //$scope.params.ValidMobilePhoneData4G={};
            if(data.data.sysCode =="BSS")
            {
              angular.copy(data.data,$scope.params.ValidMobilePhoneData2G);
            }
            else if(data.data.sysCode =="CBS")
            {
              angular.copy(data.data,$scope.params.ValidMobilePhoneData4G);
            }
            $scope.params.ddfdlb=data.data.sysCode; //记录订单返档类别2,3G或是4G，在后面返档提交的时候做判断
            $scope.params.QueryUserBySimParams.QryType= "2";
            $scope.params.QueryUserBySimParams.QryCode= $scope.params.MobilePhone;
            queryUserBySim($scope.params.QueryUserBySimParams);
          }
      },function(error){
      });
    }
    //确认提交按钮
    $scope.doClick=function()
    {
      //根据不同的网别来调用返档确认的参数构造：不要问我为什么这么多参数，因为本来就这么多参数
      //参数很多来源于 返档查询接口的数据
      if($scope.params.ddfdlb=="BSS")//2,3G
      {
        userDataReturnOk2G();
      }
      else if($scope.params.ddfdlb=="CBS")//4G
      {
        insertPsptInfo4G();
      }
    }

    //4G返档特有接口 用于身份证信息插入表
    function insertPsptInfo4G()
    {
      initInsertPsptInfo4GParams();
      ddfdService.insertPsptInfo( $scope.params.insertPsptInfo).then(
        function(data){
          userDataReturnOk4G();
        },function(error){

        });
    }

    //4G返档确认接口
    function userDataReturnOk4G()
    {
      initUserDataReturnOk4GParams();
      ddfdService.userDataReturnOk4G($scope.params.userDataReturnOk4G).then(
      function(data){
        var alertPopup=$ionicPopup.alert({
          title:'订单提交成功',
          template:"请去订单查询查看！",
          okText: '确定', // String (默认: 'OK')。OK按钮的文字。
          okType: 'item-customer-bg-darkred', // String (默认: 'button-positive')。OK按钮的类型。
        });
      },function(error){
      });
    }



    //2G确认返档
    function userDataReturnOk2G()
    {

      initUserDataReturnOk2GParams();

      ddfdService.userDataReturnOk2G($scope.params.userDataReturnOk2G).then(
        function(data){
            var alertPopup=$ionicPopup.alert({
              title:"返档",
              template:"订单提交成功，请去订单查询",
              okText: '确定', // String (默认: 'OK')。OK按钮的文字。
              okType: 'item-customer-bg-darkred', // String (默认: 'button-positive')。OK按钮的类型。
            });
        /*  else
          {
            var alertPopup=$ionicPopup.alert({
              title:"返档失败",
              template:data.respDesc,
              okText: '确定', // String (默认: 'OK')。OK按钮的文字。
              okType: 'item-customer-bg-darkred', // String (默认: 'button-positive')。OK按钮的类型。
            });
          }*/
        },function(error){
          var alertPopup=$ionicPopup.alert({
            title:"返档失败",
            template:"异常错误，请联系管理员",
            okText: '确定', // String (默认: 'OK')。OK按钮的文字。
            okType: 'item-customer-bg-darkred', // String (默认: 'button-positive')。OK按钮的类型。
          });
        });

    }


    //初始化2G返档提交参数
    function initUserDataReturnOk2GParams()
    {
      $scope.params.userDataReturnOk2G.StatusChgTime=!$scope.params.ValidMobilePhoneData2G.StatusChgTime?"":$scope.params.ValidMobilePhoneData2G.StatusChgTime;
      $scope.params.userDataReturnOk2G.ReleOfficeID=!$scope.params.ValidMobilePhoneData2G.ReleOfficeID?"":$scope.params.ValidMobilePhoneData2G.ReleOfficeID;
      $scope.params.userDataReturnOk2G.OrgType=!$scope.params.ValidMobilePhoneData2G.OrgType?"":$scope.params.ValidMobilePhoneData2G.OrgType;
      $scope.params.userDataReturnOk2G.OrgLeagalRep=!$scope.params.ValidMobilePhoneData2G.OrgLeagalRep?"":$scope.params.ValidMobilePhoneData2G.OrgLeagalRep;
      $scope.params.userDataReturnOk2G.OrgID=!$scope.params.ValidMobilePhoneData2G.OrgID?"":$scope.params.ValidMobilePhoneData2G.OrgID;
      $scope.params.userDataReturnOk2G.NativePlace=!$scope.params.ValidMobilePhoneData2G.NativePlace?"":$scope.params.ValidMobilePhoneData2G.NativePlace;
      $scope.params.userDataReturnOk2G.MaritalStatus=!$scope.params.ValidMobilePhoneData2G.MaritalStatus?"":$scope.params.ValidMobilePhoneData2G.MaritalStatus;
      $scope.params.userDataReturnOk2G.IndividualBrandID=!$scope.params.ValidMobilePhoneData2G.IndividualBrandID?"":$scope.params.ValidMobilePhoneData2G.IndividualBrandID;
      $scope.params.userDataReturnOk2G.Hobby=!$scope.params.ValidMobilePhoneData2G.Hobby?"":$scope.params.ValidMobilePhoneData2G.Hobby;
      $scope.params.userDataReturnOk2G.DevChnlID=!$scope.params.ValidMobilePhoneData2G.DevChnlID?"":$scope.params.ValidMobilePhoneData2G.DevChnlID;
      $scope.params.userDataReturnOk2G.DefaultLan=!$scope.params.ValidMobilePhoneData2G.DefaultLan?"":$scope.params.ValidMobilePhoneData2G.DefaultLan;
      $scope.params.userDataReturnOk2G.CustStatus=!$scope.params.ValidMobilePhoneData2G.CustStatus?"":$scope.params.ValidMobilePhoneData2G.CustStatus;
      $scope.params.userDataReturnOk2G.CustomerZip=!$scope.params.ValidMobilePhoneData2G.CustomerZip?"":$scope.params.ValidMobilePhoneData2G.CustomerZip;
      $scope.params.userDataReturnOk2G.CustomerType=!$scope.params.ValidMobilePhoneData2G.CustomerType?"":$scope.params.ValidMobilePhoneData2G.CustomerType;
     // $scope.params.userDataReturnOk2G.CustomerSex=!$scope.params.ValidMobilePhoneData2G.CustomerSex?"":$scope.params.ValidMobilePhoneData2G.CustomerSex;
      $scope.params.userDataReturnOk2G.CustomerOrga=!$scope.params.ValidMobilePhoneData2G.CustomerOrga?"":$scope.params.ValidMobilePhoneData2G.CustomerOrga;
      $scope.params.userDataReturnOk2G.CustomerOccp=!$scope.params.ValidMobilePhoneData2G.CustomerOccp?"":$scope.params.ValidMobilePhoneData2G.CustomerOccp;
     // $scope.params.userDataReturnOk2G.userName=!$scope.params.ValidMobilePhoneData2G.userName?$"":scope.params.ValidMobilePhoneData2G.userName;
      $scope.params.userDataReturnOk2G.CustomerLoc=!$scope.params.ValidMobilePhoneData2G.CustomerLoc?"":$scope.params.ValidMobilePhoneData2G.CustomerLoc;
      $scope.params.userDataReturnOk2G.CustomerID=!$scope.params.ValidMobilePhoneData2G.CustomerID?"":$scope.params.ValidMobilePhoneData2G.CustomerID;
      $scope.params.userDataReturnOk2G.CustomerEmail=!$scope.params.ValidMobilePhoneData2G.CustomerEmail?"":$scope.params.ValidMobilePhoneData2G.CustomerEmail;
     // $scope.params.userDataReturnOk2G.CustomerBirth=!$scope.params.ValidMobilePhoneData2G.CustomerBirth?"":$scope.params.ValidMobilePhoneData2G.CustomerBirth;
     // $scope.params.userDataReturnOk2G.CustomerAddr=!$scope.params.ValidMobilePhoneData2G.CustomerAddr?"":$scope.params.ValidMobilePhoneData2G.CustomerAddr;
      $scope.params.userDataReturnOk2G.CustLoc=!$scope.params.ValidMobilePhoneData2G.CustLoc?"":$scope.params.ValidMobilePhoneData2G.CustLoc;
      $scope.params.userDataReturnOk2G.CorpBrandID=!$scope.params.ValidMobilePhoneData2G.CorpBrandID?"":$scope.params.ValidMobilePhoneData2G.CorpBrandID;
      $scope.params.userDataReturnOk2G.ContactZip=!$scope.params.ValidMobilePhoneData2G.ContactZip?"":$scope.params.ValidMobilePhoneData2G.ContactZip;
     // $scope.params.userDataReturnOk2G.ContactPhone=!$scope.params.ValidMobilePhoneData2G.ContactPhone?"":$scope.params.ValidMobilePhoneData2G.ContactPhone;
     // $scope.params.userDataReturnOk2G.ContactPerson=!$scope.params.ValidMobilePhoneData2G.ContactPerson?"":$scope.params.ValidMobilePhoneData2G.ContactPerson;
      $scope.params.userDataReturnOk2G.ContactEmail=!$scope.params.ValidMobilePhoneData2G.ContactEmail?"":$scope.params.ValidMobilePhoneData2G.ContactEmail;
     // $scope.params.userDataReturnOk2G.ContactAddr=!$scope.params.ValidMobilePhoneData2G.ContactAddr?$"":scope.params.ValidMobilePhoneData2G.ContactAddr;
      $scope.params.userDataReturnOk2G.CertType=!$scope.params.ValidMobilePhoneData2G.CertType?"":$scope.params.ValidMobilePhoneData2G.CertType;
     // $scope.params.userDataReturnOk2G.IdNum=!$scope.params.ValidMobilePhoneData2G.IdNum?"":$scope.params.ValidMobilePhoneData2G.IdNum;
      $scope.params.userDataReturnOk2G.CertExpireDate=!$scope.params.ValidMobilePhoneData2G.CertExpireDate?"":$scope.params.ValidMobilePhoneData2G.CertExpireDate;
     // $scope.params.userDataReturnOk2G.userAddress=!$scope.params.ValidMobilePhoneData2G.userAddress?"":$scope.params.ValidMobilePhoneData2G.userAddress;

     // $scope.params.userDataReturnOk2G.CustomerID=$scope.params.ValidMobilePhoneData2G.CustomerID;
    //$scope.params.userDataReturnOk2G.CustomerLoc=$scope.params.ValidMobilePhoneData2G.CustomerLoc;
    //$scope.params.userDataReturnOk2G.CustomerType=$scope.params.ValidMobilePhoneData2G.CustomerType;
    //  $scope.params.userDataReturnOk2G.CertType=$scope.params.ValidMobilePhoneData2G.CertType;
    //  $scope.params.userDataReturnOk2G.ReleOfficeID=$scope.params.ValidMobilePhoneData2G.ReleOfficeID;
     // $scope.params.userDataReturnOk2G.CertExpireDate=$scope.params.ValidMobilePhoneData2G.CertExpireDate;
      $scope.params.userDataReturnOk2G.ContactPerson=trimStr($scope.params.ValidMobilePhoneData2G.ContactPerson);
      $scope.params.userDataReturnOk2G.ContactPhone=$scope.params.ValidMobilePhoneData2G.ContactPhone;
      $scope.params.userDataReturnOk2G.ContactAddr=trimStr($scope.params.ValidMobilePhoneData2G.ContactAddr);
     // $scope.params.userDataReturnOk2G.StatusChgTime=$scope.params.ValidMobilePhoneData2G.StatusChgTime;
      $scope.params.userDataReturnOk2G.mobilePhone=$scope.params.MobilePhone;

      $scope.params.userDataReturnOk2G.IdNum=trimStr($scope.params.IdCard.cardNo);
      $scope.params.userDataReturnOk2G.userName=trimStr($scope.params.IdCard.name);
      $scope.params.userDataReturnOk2G.CustomerAddr=trimStr($scope.params.IdCard.address);
      $scope.params.userDataReturnOk2G.CustomerSex=$scope.params.IdCard.sex=="男"?"1":"0";
      $scope.params.userDataReturnOk2G.CustomerBirth=$scope.params.IdCard.birth;
      $scope.params.userDataReturnOk2G.userAddress=trimStr($scope.params.IdCard.address);
    }

    //初始化4G返档提交参数
    function initUserDataReturnOk4GParams()
    {
      var strFromTo= new Array();
      strFromTo=$scope.params.IdCard.period.split("-");
      var ActivityLFrom=strFromTo[0];
      var ActivityLTo=strFromTo[1]=="长期"?"2050-12-31":strFromTo[1];

      $scope.params.userDataReturnOk4G.BASIC_CREDIT_VALUE=$scope.params.ValidMobilePhoneData4G.basicCreditValue;
      $scope.params.userDataReturnOk4G.CREDIT_CLASS=$scope.params.ValidMobilePhoneData4G.creditClass;
      $scope.params.userDataReturnOk4G.CUST_STATE=$scope.params.ValidMobilePhoneData4G.custState;
      $scope.params.userDataReturnOk4G.CUST_ID=$scope.params.ValidMobilePhoneData4G.custId;
      $scope.params.userDataReturnOk4G.OPEN_LIMIT=$scope.params.ValidMobilePhoneData4G.openLimit;
      $scope.params.userDataReturnOk4G.PSPT_TYPE_CODE=$scope.params.ValidMobilePhoneData4G.psptTypeCode;
      $scope.params.userDataReturnOk4G.HOME_ADDRESS=$scope.params.ValidMobilePhoneData4G.homeAddress;
      $scope.params.userDataReturnOk4G.PHONE=$scope.params.ValidMobilePhoneData4G.phone;
      $scope.params.userDataReturnOk4G.POST_ADDRESS=$scope.params.ValidMobilePhoneData4G.postAddress;
      $scope.params.userDataReturnOk4G.POST_CODE=$scope.params.ValidMobilePhoneData4G.postCode;
      $scope.params.userDataReturnOk4G.CONTACT=$scope.params.ValidMobilePhoneData4G.contact;
      $scope.params.userDataReturnOk4G.CONTACT_PHONE=$scope.params.ValidMobilePhoneData4G.contactPhone;
      $scope.params.userDataReturnOk4G.CONTACT_TYPE_CODE=!$scope.params.ValidMobilePhoneData4G.contactTypeCode?"":$scope.params.ValidMobilePhoneData4G.contactTypeCode; //无
      $scope.params.userDataReturnOk4G.WORK_NAME=$scope.params.ValidMobilePhoneData4G.workName;
      $scope.params.userDataReturnOk4G.WORK_PHONE=$scope.params.ValidMobilePhoneData4G.workPhone;
      $scope.params.userDataReturnOk4G.WORK_ADDRESS=$scope.params.ValidMobilePhoneData4G.workAddress;
      $scope.params.userDataReturnOk4G.JOB_TYPE_CODE=!$scope.params.ValidMobilePhoneData4G.jobTypeCode?"":$scope.params.ValidMobilePhoneData4G.jobTypeCode;//无
      $scope.params.userDataReturnOk4G.JOB=$scope.params.ValidMobilePhoneData4G.job;
      $scope.params.userDataReturnOk4G.EMAIL=$scope.params.ValidMobilePhoneData4G.email;
      $scope.params.userDataReturnOk4G.FAX_NBR=!$scope.params.ValidMobilePhoneData4G.faxNbr?"":$scope.params.ValidMobilePhoneData4G.faxNbr;//无
      $scope.params.userDataReturnOk4G.CUST_TAG=$scope.params.ValidMobilePhoneData4G.custTag;
      $scope.params.userDataReturnOk4G.TRADE_ID=$scope.params.ValidMobilePhoneData4G.TRADEID;
      $scope.params.userDataReturnOk4G.ORDER_TYPE=$scope.params.ValidMobilePhoneData4G.CREATE_TYPE;
      $scope.params.userDataReturnOk4G.USER_ID=$scope.params.ValidMobilePhoneData4G.userId;
      $scope.params.userDataReturnOk4G.SERIAL_NUMBER_NO=$scope.params.MobilePhone;
      $scope.params.userDataReturnOk4G.ACCT_ID=$scope.params.ValidMobilePhoneData4G.acctId;
      $scope.params.userDataReturnOk4G.ACCEPT_DATE=$scope.params.ValidMobilePhoneData4G.acceptDate;
      $scope.params.userDataReturnOk4G.TRADE_CITY_CODE=$scope.params.ValidMobilePhoneData4G.tradeCityCode;
      $scope.params.userDataReturnOk4G.CITY_CODE=$scope.params.ValidMobilePhoneData4G.cityCode;
      //$scope.params.userDataReturnOk.order.NET_TYPE_CODE=$scope.params.ValidMobilePhoneData.TRADEID;//固定写死
      $scope.params.userDataReturnOk4G.CANCEL_TAG=$scope.params.ValidMobilePhoneData4G.cancelTag;
      $scope.params.userDataReturnOk4G.IN_MODE_CODE=$scope.params.ValidMobilePhoneData4G.inModeCode;
      $scope.params.userDataReturnOk4G.PRODUCT_ID=$scope.params.ValidMobilePhoneData4G.productId;
      $scope.params.userDataReturnOk4G.BRAND_CODE=$scope.params.ValidMobilePhoneData4G.brandCodeForTrade;
      $scope.params.userDataReturnOk4G.GROUPMARK=$scope.params.ValidMobilePhoneData4G.groupMark;
      $scope.params.userDataReturnOk4G.CUST_ID_FOR_GROUP=$scope.params.ValidMobilePhoneData4G.custIdForGroup;
      $scope.params.userDataReturnOk4G.CUST_NAME=$scope.params.IdCard.name;
      $scope.params.userDataReturnOk4G.PSPT_ID=$scope.params.IdCard.cardNo;
      $scope.params.userDataReturnOk4G.SEX=$scope.params.IdCard.sex=="男"?"1":"0";;
      $scope.params.userDataReturnOk4G.PSPT_END_DATE=ActivityLTo;
      $scope.params.userDataReturnOk4G.PSPT_ADDR=$scope.params.IdCard.address;
      $scope.params.userDataReturnOk4G.MobilePhone=$scope.params.MobilePhone;
    }
    //初始化4G特有接口，插入实名信息；参数初始化
    function initInsertPsptInfo4GParams()
    {
      //$scope.params.IdCard.period="20110901-20210901";
      var strFromTo= new Array();
      strFromTo=$scope.params.IdCard.period.split("-");
      var ActivityLFrom=strFromTo[0];
      var ActivityLTo=strFromTo[1]=="长期"?"2050-12-31":strFromTo[1];

      $scope.params.insertPsptInfo.Name=trimStr($scope.params.IdCard.name);
      $scope.params.insertPsptInfo.Sex=$scope.params.IdCard.sex=="男"?"1":"0";//1
      $scope.params.insertPsptInfo.Nation=trimStr($scope.params.IdCard.ethnicity);
      $scope.params.insertPsptInfo.CheckType="01";
      $scope.params.insertPsptInfo.folkCode=getFolkCode($scope.params.IdCard.ethnicity);
      $scope.params.insertPsptInfo.CardReaderId="";
      $scope.params.insertPsptInfo.Born=$scope.params.IdCard.birth;
      $scope.params.insertPsptInfo.Address=trimStr($scope.params.IdCard.address);
      $scope.params.insertPsptInfo.CardNo=trimStr($scope.params.IdCard.cardNo);
      $scope.params.insertPsptInfo.Police=trimStr($scope.params.IdCard.authority);
      $scope.params.insertPsptInfo.ActivityLFrom=ActivityLFrom;
      $scope.params.insertPsptInfo.ActivityLTo=ActivityLTo;
      $scope.params.insertPsptInfo.PhotoBuffer="";



    }

    //SIM卡号和手机号互查
    function queryUserBySim(params)
    {
      //调用通过手机号查询iccid的接口
      ddfdService.queryUserBySim(params).then(
        function(data){
          if(data.respCode=="-1")//查询SIM卡号失败
          {
            var alertPopup=$ionicPopup.alert({
              title:'查询SIM卡号失败',
              template:data.respDesc,
              okText: '确定', // String (默认: 'OK')。OK按钮的文字。
              okType: 'item-customer-bg-darkred', // String (默认: 'button-positive')。OK按钮的类型。
            });
          }
          else
          {
            if($scope.params.QueryUserBySimParams.QryType=="1") //根据SIM卡号查号码
            {
              //console.log("我给手机赋值");
              $scope.params.MobilePhone=data.data.UserNum;
            }
            else //根据号码查询SIM卡号
            {
              //console.log("我给SIM卡号赋值");
              $scope.params.BarSimCard.text=data.data.UserNum;
            }
          }
        },function(error){

        });

  }
     $scope.resetddfd=function(){
       $scope.params.tijiao=0;
       $scope.params.IdCard={};
       $scope.params.BarSimCard={};
       $scope.params.MobilePhone='';
     }


  }]);
